package com.wuba.rxjavademo.lyz.day0602;

import com.wuba.rxjavademo.lyz.BaseDemo;

import rx.subjects.AsyncSubject;
import rx.subjects.BehaviorSubject;
import rx.subjects.PublishSubject;
import rx.subjects.ReplaySubject;

/**
 * Created by liyaxing on 2016/6/7.
 */
public class Demo04 extends BaseDemo {

    public static void main(String[] ss){

        PublishSubject<String> publishSubject = PublishSubject.create() ;
        publishSubject.onNext("aaa");
        publishSubject.subscribe(mSubscriber) ;
        publishSubject.onNext("bbb");
        publishSubject.onCompleted();
        publishSubject.onNext("ccc");

        BehaviorSubject<Integer> behaviorSubject = BehaviorSubject.create();
        behaviorSubject.onNext(0);
        behaviorSubject.onNext(1);
        behaviorSubject.subscribe(mSubscriber) ;
        behaviorSubject.onNext(2);
        behaviorSubject.onNext(3);
        behaviorSubject.onCompleted();
        behaviorSubject.onNext(4);

        ReplaySubject<Integer> replaySubject = ReplaySubject.create();
        replaySubject.onNext(0);
        replaySubject.onNext(1);
        replaySubject.subscribe(mSubscriber) ;
        replaySubject.onNext(2);
        replaySubject.onNext(3);
        replaySubject.onCompleted();
        replaySubject.onNext(4);

        AsyncSubject<Integer> asyncSubject = AsyncSubject.create();
        asyncSubject.onNext(0);
        asyncSubject.onNext(1);
        asyncSubject.subscribe(mSubscriber) ;
        asyncSubject.onNext(2);
        asyncSubject.onNext(3);
        asyncSubject.onCompleted();
        asyncSubject.onNext(4);

        sleepOnMainThread();
    }




}
